{__NOLAYOUT__}

{js href="__JS__/ajaxfileupload.js"}
<form data-method="post" data-action="{:url('admin/category/saveDesc')}" data-submit="ajax" data-validate="true" class="form-horizontal" >
    <div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                    <h3 class="modal-title">{$data['id']?lang('Edit'):lang('Add')}{:lang('Desc')}</h3>
                </div>
                <input type="hidden" name="id" value="{$data.id ?? ''}">
                <div class="modal-body">
                    <div class="modal-body-content">
                        <div class="form-group must">
                            <label class="col-sm-3 control-label">{:lang('FromCategory')}</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" name="" maxlength="11" placeholder="{:lang('Up_characters',['langth' =>25])}" required value="{$data.category_name ?? ''}"  disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">{:lang('CategoryUrl')}</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control" name="c_url" maxlength="11" placeholder="{:lang('Up_characters',['langth' =>25])}" required value="{$data.c_url ?? ''}"  >
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-sm-3 control-label">{:lang('CategoryImg')}</label>
                            <div class="col-sm-7">
                                <input type="file" class="form-control equalto uploadIMG" id="uploadIMG" name="uploadIMG" multiple accept="image/*" >
                                <div class="savePicture">
                                    <a href="#">保存</a>
                                </div>
                                <div class="canclePicture">
                                    <a href="javascript:void">取消</a>
                                </div>
                                <input type="hidden" class="form-control equalto" name="c_img"  required value="{$data.c_img ?? ''}">
                                <img src="" width="100%" class="uploadSHOW">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">{:lang('CategoryDesc')}</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control equalto" name="c_desc" rangelength="[2,50]" placeholder="{:lang('Range_characters',['minLangth' =>2,'maxLangth' => 50])}" required value="{$data.c_desc ?? ''}">
                            </div>
                        </div>


                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">{:lang('Cancel')}</button>
                    <button type="submit" class="btn btn-primary">{:lang('Save')}</button>
                </div>
            </div>
        </div>
    </div>
</form>
<script>

    $('.savePicture').click(function(){
        console.log($('#uploadIMG').val());
        $.ajaxFileUpload({
            url: '/admin/category/uploadImg',
            type: 'post',
            secureuri: false, //一般设置为false
            fileElementId: 'uploadIMG', // 上传文件的id、name属性名
            dataType: 'json',
            success:function(list){
                var errCode = list.codeNum;
                var errMsg  = list.msg;
                //errCode为0、1、2、3、5、6均为上传不成功
                if(errCode==0||errCode==1||errCode==2||errCode==3||errCode==5||errCode==6){
                    $('.choosePic span').html(errMsg);
                    return;
                } else if(errCode == 4){
                    popSetting.hide();
                    $('.userImg img').attr('src',list.path);
                    $('.site-info img').attr('src',list.path);
                }
            },
            error:function(data, status, e){
                alert(e)
            }
        });
    });
</script>
